import pymysql
import datetime
from hashlib import sha1
from settings import dbParmas
dbParmas['db'] = 'bbs'
conn = pymysql.Connect(**dbParmas)
cursor = conn.cursor()
try:
    username = input('请输入用户名')
    password = input('请输入您的密码')
    password = sha1(password.encode('utf8')).hexdigest()
    sql = "select username,usertype,password,regtime,email from user where username=%s and password=%s"
    result = cursor.execute(sql,[username, password])
    if result > 0:
        print('登录成功')
        data = cursor.fetchall()
        for i in data[0]:
            print(i, end='  ')
except Exception as e:
    print(e)
finally:
    cursor.close()
    conn.close()
